package hu.dobrosi.dinkycam.j2me;

import hu.dobrosi.dinkycam.gwt.client.StaticUtil;

import java.util.Date;

import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.PushRegistry;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class DinkycamMIDlet extends MIDlet {
	protected static final String VERSION = "1.0";
	private DinkycamApp app;

	public DinkycamMIDlet() {
		// TODO Auto-generated constructor stub
	}

	private void scheduleMIDlet(long deltatime) throws ClassNotFoundException,
			ConnectionNotFoundException, SecurityException {

		String cn = this.getClass().getName();
		// Get the current time by calling Date.getTime()
		Date alarm = new Date();
		long t = PushRegistry.registerAlarm(cn, alarm.getTime() + deltatime);
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
	}

	protected void pauseApp() {
		// TODO Auto-generated method stub
	}

	protected void startApp() throws MIDletStateChangeException {
		StaticUtil.VERSION_MIDLET = getAppProperty("MIDlet-Version");
		StaticUtil.MIDLETUPDATE_URL = "http://m.dinkycam.com/index.jsp?currentVersion="
				+ StaticUtil.VERSION_MIDLET;
		app = new DinkycamApp(this);
	}

	public static void vibrate() {
		Display.getDisplay(DinkycamApp.midlet).vibrate(800);
	}
}
